<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      body,
      ul {
        margin: 0;
        padding: 0;
      }
      body {
        width: 100%;
        height: 100%;
        background-image: url(../../images/grid.png);
      }
      svg {
        background-color: rgba(255, 0, 0, 0.1);
      }
    </style>
  </head>
  <body>
    <svg width="300" height="300" xmlns="https://www.w3.org/2000/svg">
      <defs>
        <!-- 默认的渐变 -->
        <linearGradient id="gradient1">
          <stop offset="0%" stop-color="red" />
          <stop offset="50%" stop-color="green" />
          <stop offset="100%" stop-color="blue" />
        </linearGradient>

        <!-- 指定渐变的方向 -->
        <linearGradient id="gradient2" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0%" stop-color="red" />
          <stop offset="50%" stop-color="green" />
          <stop offset="100%" stop-color="blue" />
        </linearGradient>

        <!-- 通过形变 渐变色 -->
        <linearGradient id="gradient3" gradientTransform="rotate(90)">
          <stop offset="0%" stop-color="red" />
          <stop offset="50%" stop-color="green" />
          <stop offset="100%" stop-color="blue" />
        </linearGradient>
      </defs>

      <rect x="10" y="10" width="100" height="50" fill="url(#gradient3)"></rect>
    </svg>
  </body>
</html>
